package com.fndsoft.police.xuancheng.ui.common;

import android.view.View;
import android.view.View.OnClickListener;
import android.widget.EditText;
import android.widget.TextView;

import com.fndsoft.police.xuancheng.R;
import com.fndsoft.police.xuancheng.domain.ThreadMessage;
import com.fndsoft.police.xuancheng.listener.CommonListener;
import com.fndsoft.police.xuancheng.net.OperateCode;
import com.fndsoft.police.xuancheng.ui.base.BaseAc;
import com.fndsoft.police.xuancheng.util.ViewUtil;
import com.fndsoft.police.xuancheng.view.TitleBar.TitleSyle;
import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.ViewInject;

/**
 * 大文本的界面,包含只读和编辑
 * 
 * @author carlos carlosk@163.com
 * @version 创建时间：2014年4月6日 上午1:53:51
 */

public class BigContentAc extends BaseAc {
	private static String title;// 标题
	private static String content;// 内容
	private static boolean isEditAble;// 是否可以编辑
	private static CommonListener commonListener;

	public static void lauch(String title1, String content1,
			boolean isEditAble1, CommonListener commonListener) {
		title = title1;
		content = content1;
		isEditAble = isEditAble1;
		BigContentAc.commonListener = commonListener;
		BaseAc.currentActivity.startCOActivity(BigContentAc.class);
	}

	@Override
	public void doResponseFinished(OperateCode operateCode,
			ThreadMessage threadMessage) {

	}

	@ViewInject(R.id.tvContent)
	private TextView tvContent;
	@ViewInject(R.id.etContent)
	private EditText etContent;

	@Override
	protected void installViews() {
		// 界面
		setContentView(R.layout.big_content_ac);
		ViewUtils.inject(this);
		ViewUtil.setViewsGone(tvContent, etContent);
		// 判断是只读还是非只读
		if (!isEditAble) {
			initTitleSyle(TitleSyle.LeftBtn, title);
			tvContent.setText(content);
			ViewUtil.setViewsVisible(tvContent);
			return;
		}
		initTitleSyle(TitleSyle.TwoBtn, title);
		mTitleBar.rightBtn1
				.setBackgroundResource(R.drawable.nav_icon_yes_select);
		etContent.setHint(title);
		etContent.setText(content);
		ViewUtil.setViewsVisible(etContent);
		mTitleBar.rightBtn1.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// 点击了以后把内容写到改变后的对象里
				String content = etContent.getText().toString();
				if (null != commonListener) {
					commonListener.onClickOne(content);
				}
				finish();
			}
		});
	}

	@Override
	protected void initData() {

	}

	@Override
	public boolean isCustomBackBtnEvent() {
		return false;
	}

}
